import { createChunk } from '@/hooks/useShardFileUpload'

addEventListener('message', async e => {
  const {
    file,
    chunkSize,
    startChunkIndex: start,
    endChunkIndex: end,
  } = e.data;
  const proms = [];
  for (let i = start; i < end; i++) {
    proms.push(createChunk(file, i, chunkSize));
  }
  // 拿到所有的chunks
  const chunks = await Promise.all(proms);
  postMessage(chunks)
})
